package com.qk.common.util;

/**
 * 操作当前登录用户信息
 */
public class CurrentUserHolders {
    private CurrentUserHolders() {
    }
    // 当前登录用户id
    private static final ThreadLocal<Integer> CURRENT_USER_ID = new ThreadLocal<>();
    // 当前登录用户名
    private static final ThreadLocal<String> CURRENT_USER_NAME = new ThreadLocal<>();

    public static void setCurrentUserId(Integer userId) {
        CURRENT_USER_ID.set(userId);
    }
    public static void setCurrentUserName(String userName) {
        CURRENT_USER_NAME.set(userName);
    }

    public static Integer getCurrentUserId() {
        return CURRENT_USER_ID.get();
    }
    public static String getCurrentUserName() {
        return CURRENT_USER_NAME.get();
    }


    public static void removeCurrentUserId() {
        CURRENT_USER_ID.remove();
    }
    public static void removeCurrentUserName() {
        CURRENT_USER_NAME.remove();
    }
}